package org.mbcorp.sar.controller;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import org.mbcorp.sar.service.ArchivoService;
import org.mbcorp.sar.service.AreaService;
import org.mbcorp.sar.service.SolicitudService;
import org.mbcorp.sar.service.TipoRequerimientoService;
import org.mbcorp.sar.validator.SolicitudValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.context.MessageSource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@PreAuthorize(value = "isAuthenticated()")
@Controller
public class EstimarSolicitudesController {

	@Autowired
    private MessageSource messageSource;

	@Autowired
	private SolicitudService solicitudService;
	
	@Autowired
	private AreaService areaService;
	
	@Autowired
	private ArchivoService archivoService;
	
	@Autowired
	private TipoRequerimientoService tipoRequerimientoService;
	
	@Autowired
	private SolicitudValidator solicitudValidator;
	
	@InitBinder
	public void initDateBinder(final WebDataBinder dataBinder, final Locale locale) {
	    final String dateformat = this.messageSource.getMessage("date.format", null, locale);
	    final SimpleDateFormat sdf = new SimpleDateFormat(dateformat);
	    sdf.setLenient(false);
	    dataBinder.registerCustomEditor(Date.class, new CustomDateEditor(sdf, false));
	}

	@RequestMapping(value = "/consultarEstimacion/{id}", method = RequestMethod.GET)
	public String mostrarDetalle(@PathVariable Integer id, Model model) {
		//por implementar
	return "views/registrarEstimacion";
	   }
}
